<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<!-- <script src='/Public/jquery.min.js'></script> -->
  <script src="https://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
  
	<script src='/Public/foundation/js/foundation.min.js'></script>
	<link rel="stylesheet" href="/Public/foundation/css/foundation.min.css">
  <script src='/Public/jquery.cityselect.js'></script>
  <script src='/Public/jquery.datetimepicker.full.js'></script>
  <link rel="stylesheet" href="/Public/jquery.datetimepicker.css">
   <script src="http://cdn.static.runoob.com/libs/foundation/5.5.3/js/vendor/modernizr.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<nav class="top-bar" data-topbar>
  <ul class="title-area">
    <li class="name">
      <h1><a href="#">后台管理</a></h1>
    </li>
  </ul>

  <section class="top-bar-section">
    <ul class="right">
      <li><a href=""><?php echo (session('name')); ?></a></li>
      <li><a href="<?php echo U('Login/doLogout');?>">退出</a></li>
    </ul>
  </section>
</nav>

<div class="small-2 columns">
<ul class="side-nav">
 <?php if(is_array($nav)): $i = 0; $__LIST__ = $nav;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li><a href="<?php echo U($vo['url']);?>" target='<?php echo ($vo["target"]?"_blank":null); ?>'><?php echo ($vo["mname"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
    </ul>
</div>
<div class="small-10 columns">

    <center>
        <table style="margin-top: 5%">
            <theat>
                <th>考试名称</th>
                <th style="text-align: center">考试占比</th>
            </theat>
            <tbody>
            <?php if(is_array($res)): $i = 0; $__LIST__ = $res;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$res): $mod = ($i % 2 );++$i;?><tr>
                    <td><?php echo ($res["exam_name"]); ?></td>
                    <td>
                        <input type="text" class="as" value="<?php echo ($res["percent"]); ?>" disabled style="height:25px;border-radius: 5px" onblur="addP()">
                        <input type="hidden" class="ds" value="<?php echo ($res["id"]); ?>">
                    </td>
                </tr><?php endforeach; endif; else: echo "" ;endif; ?>
            <tr>
                <td>总和</td>
                <td id="zh"><?php echo ($nu); ?></td>
            </tr>
            </tbody>
            <tfoot>
                <td colspan="2" style="padding-left:37% ">
                    <buttom class="button tiny  radius xg" onclick="xg()">修改</buttom>
                    <buttom class="button tiny  radius bc" style="display:none" onclick="bc()">保存</buttom>
                </td>
            </tfoot>
        </table>
    </center>
    <script>
        function xg() {
            $('.xg').hide();
            $('.bc').show();
            $('.as').prop('disabled',false);
        }
        function bc() {
            if ($('#zh').html()=='100'){
                $('.bc').hide();
                $('.xg').show();
                $('.as').prop('disabled', true);
                var did = $('.ds').map(function () {return $(this).val();}).get().join(',');
                var per = $('.as').map(function () {return $(this).val();}).get().join(',');
                var data={
                    id:did,
                    per:per,
                };
                $.post("<?php echo U('Percent/add');?>",data,function (data) {
                    alert(data);
                })
            }else{
                alert('总和不为100,请修改');
            }
        }
        function addP() {
            var a=$('.as').map(function (){return $(this).val();}).get();
            var b=0;
            for(i in a){
                b=b+parseInt(a[i]);
            }
            $('#zh').html(b);
        }
    </script>

</div>

</body>
</html>